﻿# Get-Content .\LogFile.txt  | Measure-Object
# Get-Content .\LogFile.txt -Tail 1000 | ForEach-Object {$_}
# $file = "D:\TEST.txt" 
# (Get-Content $file | Select-Object -Skip 3 -First ) | Set-Content $file
$date = Get-Date -Format yyyyMMdd
$Comname = gc env:computername
[string]$Comnum = "000"
$Log_path = "X:\Freigabe_Ordner\Arbeiten\Senna\logfile_scirpt\logfile"
$File_endung = ".txt"
$File_log_name = "\LogFile$File_endung"
 
[int]$count = (Get-Content  $Log_path$File_log_name | 
Measure-Object | 
Select-Object Count).Count

[int]$Zbehalten = 1090 #Hier wird Festgelegt wie viele zeilen von anfang an behalten werden sollen
[int]$Zabziehen = $count - $Zbehalten #Hier wird festgelegt wie viele zeilen in ein anderes Verschoben werden
[int]$NumName = (Get-ChildItem  $Log_path | Measure-Object | Select-Object Count).count
[int]$NumName_ergebnis = $NumName - 001 
[int]$Comnum_richtig = $Comnum + $NumName_ergebnis

(Get-Content $Log_path$File_log_name | Select-Object -First $Zabziehen ) | Out-File $Log_path\$Comname.LogFile.$Comnum_richtig.$date$File_endung -Append
#$file = (Get-Content $Log_path$File_log_name | Select-Object

(Get-Content $Log_path$File_log_name | Select-Object -Skip  $Zabziehen) | Set-Content $Log_path$File_log_name

#Invoke-Item $Log_path$File_log_name